require 'test/unit'
require './IupacConverter'
class IupacConverterTest < Test::Unit::TestCase
    def testSmilesParser
      testSet = {"C(C(C(C(C(C)))))"=>"Hexane",
                  "CC(C)(C)CCCCCCC"=>"2,2-Dimethylnonane",
                  "CCCCCCCCC(CCCCCCCCC)CCCCCCCCC"=>"10-Octylnonadecane",
                  "CCCCC(C)"=>"Hexane",
                  "CC(C)"=>"Propane",
                  "C(C)(C)"=>"Propane",
                  " C   C	C \n"=>"Propane",
                  "C(C)(C)C"=>"2-Methylpropane",
                  "C(C)CC"=>"Butane",
                  "CCC(C)(C)CC"=>"3,3-Dimethylpentane",
                  "CCC(C)CC"=>"3-Methylpentane",
                  "CCCCC(C(C)C)CCCC"=>"5-Isopropylnonane",
                  "CCCCC(CC(C)C)CCCC"=>"5-Isobutylnonane",
                  "CCC(C)(C)C(CC)CCC"=>"4-Ethyl-3,3-dimethylheptane",
                  "CCCC(CC)C(C)CCC"=>"4-Ethyl-5-methyloctane",
                  "CC(C)C(C)CC(C)C"=>"2,3,5-Trimethylhexane",
                  "CCCC(C(C)C)C(CCC)CCC"=>"4-Isopropyl-5-propyloctane",
                  "CCCCC(C(C)CC)CCCC"=>"5-sec-Butylnonane",
                  "CCCCCCC(CCC(C)C)CCCCCC"=>"7-Isopentyltridecane",
                  "CCCCCC(CC(C)(C)C)CCCCC"=>"6-Neopentylundecane",
                  "CCCCCC(C(C)(C)CC)CCCCC"=>"6-tert-Pentylundecane",
                  "CCCC(CCC)C(C)CCCC"=>"5-Methyl-4-propylnonane",
                  "CC(C)CCCCC(C)C(C)CC"=>"2,7,8-Trimethyldecane",
                  "CCCCCCC(C(C)CCCC)CCCCCC"=>"7-(1-Methylpentyl)tridecane",
                  "CCCCCCC(CC(C)CCC)CCCCCC"=>"7-(2-Methylpentyl)tridecane",
                  "CCCCCCCC(CCCCC(C)C)CCCCCCC"=>"8-(5-Methylhexyl)pentadecane",
                  "CCCCCC(C(C)(C)C)CCCCC"=>"6-tert-Butylundecane",
                  "CCCCCCC(CCCC(C)C)CCCCCC"=>"7-Isohexyltridecane",
                  "CCCCC(CC)CC(C(C)C(C)CCC)CCCCCC"=>"7-(1,2-Dimethylpentyl)-5-ethyltridecane",
                  "CCCCCC(C(C)CCC)CC(CC(C)CC)CCCCC"=>"6-(1-Methylbutyl)-8-(2-methylbutyl)tridecane",
                  "CC(C)CCC(C(CC)(CC)CC)(C(CC)(CC)CC)CCCCC"=>"5,5-Bis(1,1-diethylpropyl)-2-methyldecane",
                  "CCCCC(CCC)C(C(C(C)C)CCCC)CCCCCC"=>"6-(1-Isopropylpentyl)-5-propyldodecane",
                  "CCC(CC)CC(C)CC(CC(C)CC(C)CC)(CC(C)CC(C)CC)CC(C)CC(C)CC"=>"7,7-Bis(2,4-dimethylhexyl)-3-ethyl-5,9,11-trimethyltridecane"}
      testSet.each do |key, value|
        assert_equal value, IupacConverter.new.buildFromMolecule(Molecule.new(key))
      end
    end
end